Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 1, 2025

✅ Implementation Complete: Add Pixel Precision for Helping Precision Placement

Successfully implemented a zoomed preview feature similar to PowerToys Color Picker that provides pixel-perfect point placement for image transformations and measurements.


📋 Summary

This PR adds a Pixel Precision Zoom control that automatically appears when users are placing or adjusting points for:

  • Image transformation corner markers
  • Distance, angle, rectangle, circle, and polygon measurements
  • Any operation requiring precise point placement

The zoom preview shows a 6x magnified view of the image region under the cursor with a red crosshair and pixel coordinates, enabling pixel-perfect accuracy.


✨ Key Features

  • 6x Magnification - Clear view of individual pixels
  • Automatic Activation - Appears when measurement tools selected or transform mode active
  • Always Visible by Cursor - Follows cursor continuously in precision modes
  • Independent of Canvas Zoom - Not affected by canvas zoom level, maintains constant size
  • Circular Shape - True circular clipping for professional magnifier appearance
  • Smart Positioning - Positions near cursor without blocking the target
  • Real-time Updates - Follows cursor movement smoothly
  • Visual Indicators - Red crosshair and coordinate display
  • Professional Design - Circular window with blue accent border matching app theme
  • Universal Integration - Works with all measurement tools and transform corners
  • Performant - Efficient rendering using WPF bitmap APIs

🔄 Recent Updates

Circular Clipping (Latest)

  • True circular shape - Added EllipseGeometry clip to make control perfectly circular
  • Professional appearance - Mimics traditional magnifying glass/loupe tools
  • Clean edges - Content properly clipped to circular boundary

Canvas Independence

  • Moved outside ShapeCanvas - Zoom control now positioned in MainGrid, not affected by canvas transforms
  • Constant size - Preview maintains 150×150px size regardless of canvas zoom level
  • Accurate positioning - Coordinates properly transformed from ShapeCanvas to MainGrid space

Visibility Improvements

  • Zoom now appears when hovering with any measurement tool selected (not just when clicking)
  • Zoom stays visible throughout precision operations
  • Only hides when explicitly leaving precision modes
  • Follows cursor continuously, ensuring it's always visible where needed

📁 Files Changed

New Files (4)

  1. MagickCrop/Controls/PixelPrecisionZoom.xaml - UserControl XAML definition with circular clipping
  2. MagickCrop/Controls/PixelPrecisionZoom.xaml.cs - Control logic and image magnification
  3. PIXEL_PRECISION_ZOOM.md - Comprehensive feature documentation
  4. PIXEL_PRECISION_VISUAL_GUIDE.md - ASCII art diagrams and visual layouts

Modified Files (2)

  1. MagickCrop/MainWindow.xaml - Control placement in MainGrid (outside ShapeCanvas)
  2. MagickCrop/MainWindow.xaml.cs - Zoom management and coordinate transformation

🔧 Implementation Details

Architecture

MainGrid (no transforms)
├── ShapeCanvas (has ScaleTransform + TranslateTransform)
│   └── Image, markers, measurements (scaled with canvas)
└── PixelPrecisionZoom (NOT scaled, always constant size)
    └── Grid with EllipseGeometry clip (perfect circle)
        ├── Circular Border (150x150px, blue #0066FF)
        ├── Viewbox with Zoom Canvas
        │   └── Image (magnified 6x)
        ├── Crosshair Overlay (red lines + center dot)
        └── Coordinate Display (X, Y pixel position)

Circular Clipping

The control uses EllipseGeometry for true circular clipping:

<Grid.Clip>
    <EllipseGeometry Center="75,75" RadiusX="75" RadiusY="75" />
</Grid.Clip>

This creates a perfect 150px diameter circle that clips all content.

Coordinate Transformation

The zoom control receives mouse positions in ShapeCanvas coordinates but needs to position itself in MainGrid coordinates:

Point mainGridPosition = ShapeCanvas.TransformToAncestor(MainGrid).Transform(mousePosition);

This ensures the zoom preview appears at the correct screen location even when the canvas is zoomed or panned.


🎯 Benefits

Before This Feature

❌ Hard to align corners precisely with document edges
❌ Difficult to target small features or specific pixels
❌ No visual feedback during point placement
❌ Trial and error for pixel-perfect placement

After This Feature

✅ See exactly which pixel you're targeting
✅ 6x magnified view shows fine details clearly
✅ Red crosshair indicates exact target position
✅ Pixel coordinates provide numeric reference
✅ Real-time preview follows cursor continuously
✅ Always visible when precision is needed
✅ Maintains constant size regardless of canvas zoom
✅ Professional circular magnifier appearance


This feature brings MagickCrop's precision capabilities to a professional level, making it easier than ever to achieve pixel-perfect accuracy in image transformations and measurements! 🎯✨

<issue_title>Add pixel precision for helping the precision placement</issue_title>
><issue_description>Similar to other precision utilities like color picker (PowerToys) or cropping tools, have a zoomed preview which gives the user more accurate placement of the points when setting the corners of a transformation.</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
>
>
>

Original prompt

This section details on the original issue you should resolve

<issue_title>Add pixel precision for helping the precision placement</issue_title>
<issue_description>Similar to other precision utilities like color picker (PowerToys) or cropping tools, have a zoomed preview which gives the user more accurate placement of the points when setting the corners of a transformation.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add pixel precision tool for accurate placement Add pixel precision zoom for precise point placement Nov 1, 2025
Copilot AI requested a review from TheJoeFin November 1, 2025 03:36
@TheJoeFin
Copy link
Owner

The precision window should zoom and always be visible by the cursor @copilot

- Zoom now appears when hovering with any measurement tool selected
- Zoom stays visible during tool usage, not just when dragging
- Auto-shows/hides based on whether precision mode is active
- Follows cursor continuously in all precision modes
- Only hides when leaving precision operations entirely

Co-authored-by: TheJoeFin <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 1, 2025

The precision window should zoom and always be visible by the cursor @copilot

Updated in commit 1dd9a79. The pixel zoom now:

  1. Always visible by cursor - Appears when hovering with any measurement tool selected, not just when actively dragging
  2. Continuous tracking - Follows cursor smoothly throughout precision operations
  3. Smart auto-show/hide - Automatically shows when entering precision modes (measurement tools, transform mode) and hides when leaving them

The zoom will now be visible whenever you have a measurement tool selected or are in transform mode, ensuring it's always there to guide precise placement.

@TheJoeFin
Copy link
Owner

@copilot The preview follows the cursor which is good, but it should also be outside of the ShapeCanvas so it is not affected by the zoom level

- Moved zoom control from inside ShapeCanvas to MainGrid level
- Control now unaffected by canvas ScaleTransform and zoom operations
- Updated positioning to use Margin instead of Canvas.SetLeft/SetTop
- Transform coordinates from ShapeCanvas to MainGrid for correct placement
- Zoom preview maintains constant size regardless of canvas zoom level

Co-authored-by: TheJoeFin <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 1, 2025

@copilot The preview follows the cursor which is good, but it should also be outside of the ShapeCanvas so it is not affected by the zoom level

Fixed in commit 9b075ae. The PixelPrecisionZoom control is now:

  1. Outside ShapeCanvas - Moved to MainGrid level, no longer affected by canvas transforms
  2. Constant size - Maintains 150×150px regardless of canvas zoom level
  3. Properly positioned - Coordinates transformed from ShapeCanvas to MainGrid space using TransformToAncestor

The zoom preview will now stay the same size and always be clearly visible, even when zooming the canvas in/out.

@TheJoeFin
Copy link
Owner

@copilot looks good, add a clip geometry to PixelPrecisionZoom to make it a circle shape and not a square

- Added EllipseGeometry clip to Grid for true circular shape
- Center at (75,75) with radius 75 creates perfect 150px circle
- Content now properly clipped to circular boundary
- Replaces square shape with rounded corners

Co-authored-by: TheJoeFin <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 1, 2025

@copilot looks good, add a clip geometry to PixelPrecisionZoom to make it a circle shape and not a square

Done in commit bd867cf. Added EllipseGeometry clip with center at (75,75) and radius 75 to create a perfect circular shape. The control now appears as a true circle instead of a square with rounded corners.

- Adjusted PixelPrecisionZoom dimensions and geometry clipping.
- Simplified object initializations in PixelPrecisionZoom.xaml.cs.
- Cleaned up and reorganized MainWindow.xaml for clarity.
- Improved async handling and removed unused methods in MainWindow.xaml.cs.
- Enhanced readability with consistent formatting and comments.
Upgrades project to .NET 10, updates NuGet dependencies, and refactors code to use modern C# features for improved clarity and compatibility.
Added automatic centering and zoom-to-fit functionality for images, including a menu option to trigger this behavior. Ensures images are fully visible and centered when opened or on demand.
Enhances user experience by remembering the original image path and setting the save dialog's initial directory accordingly.
Improves pixel zoom logic to display only during active measurement creation or placement, removing overlay on tool selection or hover.
@TheJoeFin TheJoeFin marked this pull request as ready for review January 13, 2026 01:31
@TheJoeFin TheJoeFin merged commit 14e0143 into dev Jan 13, 2026
2 checks passed
@TheJoeFin TheJoeFin deleted the copilot/add-pixel-precision-tool branch January 13, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants